﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Han.Forms
{
    public partial class frmOdemeGirisMini : DevExpress.XtraEditors.XtraForm
    {
        public frmOdemeGirisMini()
        {
            InitializeComponent();
        }

        public Odeme ShowDialog(Kontrat kontrat)
        {
            MyKontrat = kontrat;

            if (this.ShowDialog() == DialogResult.OK)
            {
                return this.odemeBindingSource.Current as Odeme;
            }
            return null;
        }

        public Kontrat MyKontrat { get; set; }
        DBDataContext db = Program.db; 
        private void frmOdemeGirisMini_Load(object sender, EventArgs e)
        {
            kontratBindingSource.DataSource = db.Kontrats;

            masrafKalemBindingSource.DataSource = db.MasrafKalems;

            odemeBindingSource.DataSource = new Odeme();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var odeme =  odemeBindingSource.Current as Odeme;

            MyKontrat.Odemes.Add(odeme);

            this.DialogResult = DialogResult.OK;

            this.Close();
        }
    }
}
